#include "IntegralHist.h"
#include "ImageSet.h"

// Single node in a list of integral histograms
struct IntegralHistNode
{
	bool _label;					// Indicates whether this is a positive (true) or negative (false) training example
	IntegralHist* _hist;			// Pointer to image
	IntegralHistNode* next;			// Pointer to next node
	IntegralHistNode* previous;		// Pointer to previous node (allows backwards traversal)
};

// A list of integral histograms
class IntegralHistSet
{
	public:
		IntegralHistSet(ImageSet* imgset, bool label);	// Constructor
		IntegralHistSet(const IntegralHistSet &init);	// Copy Constructor
		~IntegralHistSet();								// Destructor

		// Member function
		void AddToSet(ImageSet* imgset, bool label);	// Add new histograms from an existing image set

		// Member variables
		int _n;								// Total number of images
		int _pos;							// Number of positive examples
		int _neg;							// Number of negative examples
		IntegralHistNode* _head;			// Top of the list
		IntegralHistNode* _tail;			// End of the list
};


// A list of pointers to integral histograms. Similar to a set of 
// integral histograms, except it doesn't store the memory.
class GhostSet
{
	public:
		GhostSet();							// Constructor (No arguments)
		GhostSet(IntegralHistSet* i_set);	// Constructor
		GhostSet(const GhostSet &init);		// Copy Constructor
		~GhostSet();						// Destructor

		// Operators
		GhostSet& operator=(const GhostSet& r_set);		// Assignment operator

		// Member variables
		int _n;								// Total number of images
		int _pos;							// Number of positive examples
		int _neg;							// Number of negative examples
		IntegralHistNode* _head;			// Top of the list
		IntegralHistNode* _tail;			// End of the list
};

// A class which contains two sets of pointers describing a left 
// and right set for a feature.
class SplitSet
{
	public:
		SplitSet(GhostSet* g_set, float* f_vals, float thresh);	// Constructor

		// Member function
		float InfoGain();		// Compute information gain

		// Member variables
		GhostSet _left_set;		// Left set
		GhostSet _right_set;	// Right set
};